{% block sw_rule_modal %}
<sw-modal
    class="sw-rule-modal"
    variant="full"
    :title="modalTitle"
    :is-loading="isLoading"
    @modal-close="$emit('modal-close')"
>
    {% block sw_rule_modal_basic_info %}
    <sw-container
        v-if="rule"
        columns="2fr 1fr"
        gap="0px 32px"
    >
        {% block sw_rule_modal_basic_info_name %}

        <mt-text-field
            v-model="rule.name"
            name="sw-field--rule-name"
            :label="$tc('sw-rule-modal.labelName')"
            :placeholder="$tc('sw-rule-modal.placeholderName')"
            :error="ruleNameError"
            required
        />
        {% endblock %}
        {% block sw_rule_modal_basic_info_priority %}
        <mt-number-field
            v-model="rule.priority"
            name="sw-field--rule-priority"
            :label="$tc('sw-rule-modal.labelPriority')"
            :placeholder="$tc('sw-rule-modal.placeholderPriority')"
            :error="rulePriorityError"
            required
        />
        {% endblock %}
    </sw-container>

    {% block sw_rule_modal_basic_info_description %}
    <mt-textarea
        v-if="rule"
        v-model="rule.description"
        name="sw-field--rule-description"
        :label="$tc('sw-rule-modal.labelDescription')"
        :placeholder="$tc('sw-rule-modal.placeholderDescription')"
    />
    {% endblock %}
    {% endblock %}

    {% block sw_rule_modal_condition_tree %}
    <sw-condition-tree
        v-if="rule"
        :condition-repository="ruleConditionRepository"
        :condition-data-provider-service="ruleConditionDataProviderService"
        :root-condition="null"
        association-field="ruleId"
        :association-value="rule.id"
        :association-entity="rule"
        :initial-conditions="initialConditions"
        :scopes="allowedRuleScopes"
        @conditions-changed="conditionsChanged"
    />
    {% endblock %}

    <template #modal-footer>
        {% block sw_rule_modal_footer %}
        {% block sw_rule_modal_footer_button_abort %}
        <mt-button
            size="small"
            variant="secondary"
            @click="$emit('modal-close')"
        >
            {{ $tc('global.default.cancel') }}
        </mt-button>
        {% endblock %}

        {% block sw_rule_modal_footer_button_save %}
        <mt-button
            :disabled="isLoading"
            class="sw-rule-modal__save"
            size="small"
            variant="primary"
            @click="saveAndClose"
        >
            {{ $tc('global.default.save') }}
        </mt-button>
        {% endblock %}
        {% endblock %}
    </template>
</sw-modal>
{% endblock %}
